﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LowLevelGraphics.Filter
{
    public class Deriche : BaseImageFilter
    {
        protected Smooth m_Smooth = new Smooth();
        protected HysteresisThreshold m_HysteresisThreshold = new HysteresisThreshold();
        /// <summary>
        /// Initializes a new instance of the <see cref="Deriche"/> class.
        /// </summary>
        public Deriche()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Deriche"/> class.
        /// </summary>
        /// <param name="_deriche">The _deriche.</param>
        internal Deriche(Deriche _deriche)
        {
        }

        /// <summary>
        /// Execute this Filter
        /// A Debug Statement is written if a concrete Filter is called
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            m_Smooth.Execute(_bitmap);

            //Calculation of magnitude and gradient direction

            
            //Non-maximum suppression
            

            //Hysteresis thresholding (using two tresholds)
            m_HysteresisThreshold.Execute(_bitmap);
            
            //The essential difference is in the implementation of the first two steps of the algorithm. Unlike the Canny edge detector, Deriche edge detector uses the IIR filter in the form:

            return base.Execute(_bitmap);
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new Deriche(this);
        }
    }
}
